//
//  AddPrivateTeachView.m
//  fitnessmanage
//
//  Created by wujian on 2018/1/24.
//  Copyright © 2018年 zongquankeji. All rights reserved.
//

#import "AddPrivateTeachView.h"

@implementation AddPrivateTeachView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        
        UIScrollView *scrollView = [[UIScrollView alloc] init];
        [self addSubview:scrollView];
        self.scrollView = scrollView;
        
        /**
         单节可约人数
         */
        CommonInputView *cardCourseView = [[CommonInputView alloc] init];
        cardCourseView.titleLabel.text = @"单节可约人数";
        cardCourseView.titleTF.keyboardType = UIKeyboardTypeNumberPad;
        [scrollView addSubview:cardCourseView];
        self.cardCourseView = cardCourseView;
        
        
        /**
         最小上课人数
         */
        CommonInputView *minCourseView = [[CommonInputView alloc] init];
        minCourseView.titleLabel.text = @"最小上课人数";
        minCourseView.titleTF.keyboardType = UIKeyboardTypeNumberPad;
        [scrollView addSubview:minCourseView];
        self.minCourseView = minCourseView;
        
        /**
         课程排课
         */
        UILabel *teachClassLabel = [[UILabel alloc] init];
        teachClassLabel.font = MidFont;
        teachClassLabel.textColor = CSColorFromRGB(0x999999);
        teachClassLabel.text = @"课程日期";
        [scrollView addSubview:teachClassLabel];
        self.teachClassLabel = teachClassLabel;
        
        
        /**
         开始日期
         */
        CommonBtnView *beginCourseTimeView = [[CommonBtnView alloc] init];
        beginCourseTimeView.titleLabel.text = @"开始日期";
        beginCourseTimeView.choseLabel.text = @"选择开始日期";
        beginCourseTimeView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:beginCourseTimeView];
        self.beginCourseTimeView = beginCourseTimeView;
        
        /**
         结束日期
         */
        CommonBtnView *endCourseTimeView = [[CommonBtnView alloc] init];
        endCourseTimeView.titleLabel.text = @"结束日期";
        endCourseTimeView.choseLabel.text = @"选择结束日期";
        endCourseTimeView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:endCourseTimeView];
        self.endCourseTimeView = endCourseTimeView;
        
        /**
         何时预约开发
         */
        CommonBtnView *openView = [[CommonBtnView alloc] init];
        openView.titleLabel.text = @"何时预约开发";
        openView.choseLabel.text = @"选择何时预约开发";
        openView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:openView];
        self.openView = openView;

        /**
         可约时间段
         */
        UILabel *appointClassLabel = [[UILabel alloc] init];
        appointClassLabel.font = MidFont;
        appointClassLabel.textColor = CSColorFromRGB(0x999999);
        appointClassLabel.text = @"可约时间段";
        [scrollView addSubview:appointClassLabel];
        self.appointClassLabel = appointClassLabel;
        
        /**
         开始日期
         */
        CommonBtnView *appointBeginTimeView = [[CommonBtnView alloc] init];
        appointBeginTimeView.titleLabel.text = @"开始时间";
        appointBeginTimeView.choseLabel.text = @"选择何开始时间";
        appointBeginTimeView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:appointBeginTimeView];
        self.appointBeginTimeView = appointBeginTimeView;
        
        /**
         结束日期
         */
        CommonBtnView *appointEndTimeView = [[CommonBtnView alloc] init];
        appointEndTimeView.titleLabel.text = @"结束时间";
        appointEndTimeView.choseLabel.text = @"选择结束时间";
        appointEndTimeView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:appointEndTimeView];
        self.appointEndTimeView = appointEndTimeView;
        
        /**
         间隔时间
         */
        CommonBtnView *appointLimitView = [[CommonBtnView alloc] init];
        appointLimitView.titleLabel.text = @"约课间隔时间";
        appointLimitView.choseLabel.text = @"选择间隔时间";
        appointLimitView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:appointLimitView];
        self.appointLimitView = appointLimitView;
        
        UIButton *sureBtn = [[UIButton alloc] init];
        sureBtn.backgroundColor = ButtonBackGroundColor;
        sureBtn.layer.cornerRadius = 2;
        sureBtn.layer.masksToBounds = YES;
        sureBtn.titleLabel.font = MidBigFont;
        [sureBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        [sureBtn setTitle:@"确定"];        
        [scrollView addSubview:sureBtn];
        self.sureBtn = sureBtn;
        
        [self setConstraints];
    }
    
    return self;
    
}

-(void)setConstraints{
    
    [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(self);
    }];
    
    /**
     单节可约人数
     */
    [self.cardCourseView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.scrollView);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    
    /**
     最小上课人数
     */
    [self.minCourseView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.cardCourseView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     课程排课
     */
    [self.teachClassLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.minCourseView.mas_bottom).offset(10);
        
        make.left.mas_equalTo(self.scrollView).offset(10);
    }];
    
    
    /**
     开始日期
     */
    [self.beginCourseTimeView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.teachClassLabel.mas_bottom).offset(10);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     结束日期
     */
    [self.endCourseTimeView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.beginCourseTimeView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     何时预约开发
     */
    [self.openView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.endCourseTimeView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     可约时间段
     */
    [self.appointClassLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.openView.mas_bottom).offset(10);
        
        make.left.mas_equalTo(self.teachClassLabel);
    }];
    
    /**
     开始日期
     */
    [self.appointBeginTimeView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.appointClassLabel.mas_bottom).offset(10);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     结束日期
     */
    [self.appointEndTimeView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.appointBeginTimeView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     间隔时间
     */
    [self.appointLimitView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.appointEndTimeView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    [self.sureBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
               
        make.top.mas_equalTo(self.appointLimitView.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.scrollView).offset(20);
        
        make.right.mas_equalTo(self).offset(-20);
        
        make.height.mas_equalTo(50);
    }];
}


-(void)layoutSubviews{
    
    self.scrollView.contentSize =  CGSizeMake(self.width, self.sureBtn.bottom + adaptNavagationBar);
}
@end
